 use "Colombia2017.dta", clear

*Recoding of variables

 

*Conflict victim
qui egen victima = anymatch(wc1 wc2 wc3 colwc8 colwc9), values(1)
replace victima=. if wc1==. & wc3==. &  wc2==. & colwc8==. & colwc9==.
label var victima "Victim"
label define victima 1 "Yes" 0 "No", replace
label values victima victima 


**Conflict victimization by group
egen numvictimario=rowtotal(colwc4_1 colwc4_2 colwc4_3 colwc4_4 colwc4_5 colwc4_6 colwc4_7)
recode numvictimario (3 4 =2)

label define numvict 0 "None" 1"One" 2"More than two"
label values  numvictimario numvict

gen victimaT=.
replace victimaT=0 if victima==0
replace victimaT=1 if colwc4_1==1 & numvictimario==1
replace victimaT=2 if colwc4_2==1 & numvictimario==1
replace victimaT=3 if numvictimario==1 & (colwc4_1==0 & colwc4_2==0)
replace victimaT=4 if numvictimario>1

label define victimaT 0 "None" 1 "Victim of the FARC" 2"Victim of paramilitaries" 3"Victim of another group" 4"Victim of several groups", replace
label values  victimaT victimaT


tab victimaT, gen(vic)

tab estratopri, gen(reg)

recode ur (1=0)(2=1)


*Wealth Quintiles

#delim;
/*Quintiles para todos los años*/;
ssc install sumdist, all replace;
cap drop quintall;
qui gen quintall=.;
qui gen wealthscores=.;
qui levelsof year if year<3000 & year>2004, local(K);
foreach k of local K {;
qui pca r3 r4a r5 r6 r8 r12 r14 r15 if year==`k' & ur==1;
qui predict  f1`k'u if year==`k' & ur==1;
qui sumdist f1`k'u,  n(5) qgp(quint`k'u);
qui replace quintall=quint`k'u if year==`k' & ur==1;
qui replace wealthscores=f1`k'u if year==`k' & ur==1;

qui pca r3 r4a r5 r6 r8 r12 r14 r15 if year==`k' & ur==2;
qui predict  f1`k'r if year==`k' & ur==2;
qui sumdist f1`k'r,  n(5) qgp(quint`k'r);
qui replace quintall=quint`k'r if year==`k' & ur==2;
qui replace wealthscores=f1`k'r if year==`k' & ur==2;
};

drop f1*u  f1*r quint*u quint*r wealthscore
label variable quintall "Wealth Level"



***************************************
*MODELS******************************
***************************************



**Descriptive statistics

sum colespa1 vic1 vic2 vic3 vic4 vic5 colvb27b ing4 mujer q2 ed ur quintall reg1 reg2 reg3 reg4 

*Table 2 

*Model 1

svy: reg colespa1  i.victimaT c.colvb27b ing4 mujer q2 ed ur quintall i.estratopri

*Model 2
svy: reg colespa1  i.victimaT##c.colvb27b ing4 mujer q2 ed ur quintall i.estratopri

*Install package interactplot from http://fmwww.bc.edu/RePEc/bocode/i

*Figure 2
interactplot, byplot cme bars(10) subplot(hist) level(95) scheme(rbn1mono)


*******
*Table3

svy: reg colespa1  i.victimaT##c.colvb27g ing4 mujer q2 ed ur quintall i.estratopri 

svy: reg colespa1  i.victimaT##c.colvb27e ing4 mujer q2 ed ur quintall i.estratopri 

svy: reg colespa1  i.victimaT##c.colvb27d ing4 mujer q2 ed ur quintall i.estratopri 

svy: reg colespa1  i.victimaT##c.colvb27a ing4 mujer q2 ed ur quintall i.estratopri 

svy: reg colespa1  i.victimaT##c.colvb27f ing4 mujer q2 ed ur quintall i.estratopri 

svy: reg colespa1  i.victimaT##c.colvb27c ing4 mujer q2 ed ur quintall i.estratopri 



**********
*Appendix*
**********
*Table 1A

*Model 1
svy: reg colespa1 i.victima c.colvb27b ing4 mujer q2 ed ur quintall i.estratopri

*Model 2
svy: reg colespa1  i.victima##c.colvb27b ing4 mujer q2 ed ur quintall i.estratopri


*Figure 3
interactplot, byplot cme bars(10) subplot(hist) level(95) scheme(rbn1mono)



keep sbjnum pais prov muni estratopri ur sector seccion vereda year weight1500 date duration upm q1 colespa1 colvb27a colvb27b colvb27c colvb27d colvb27e colvb27f colvb27g ing4 mujer q2 ed ur wc1 wc2 wc3 colwc8 colwc9 colwc4_1 colwc4_2 colwc4_3 colwc4_4 colwc4_5 colwc4_6 colwc4_7 r3 r4a r5 r6 r8 r12 r14 r15


